<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>获取与字符串相同的标识符对应的值</title>
</head>
<body>
<script>
    /*
      let variable = "Hello, World!";
      let variableName = "variable";


      // 评估并执行参数
      console.log(eval("123 + 456"));
      console.log(eval('123 + 456'));
      console.log(eval(123 + 456));

      let abc = 123;
      console.log(eval(abc));

      console.log(eval(variableName));
      */


    // 必须是全局变量才能通过 window 进行访问
    var variable = "Hello, World!";
    let variableName = "variable";

    console.log(window[variableName]);


</script>
</body>
</html>